/*
 * @Author: 陈宇 975155172@qq.com
 * @Date: 2024-08-14 10:58:52
 * @LastEditors: 陈宇 975155172@qq.com
 * @LastEditTime: 2024-08-19 17:25:46
 * @FilePath: \blog-web\src\router\guard\index.ts
 * @Description: 封装路由守卫
 */
import type { Router } from 'vue-router';
import { setRouteEmitter } from '@/utils/route-listener';
import setupUserLoginInfoGuard from './userLoginInfo';
import setupPermissionGuard from './permission';

function setupPageGuard(router: Router) {
  router.beforeEach(async (to) => {
    // emit route change
    setRouteEmitter(to);
  });
}

export default function createRouteGuard(router: Router) {
  setupPageGuard(router);
  setupUserLoginInfoGuard(router);
  setupPermissionGuard(router);
}
